#!/bin/sh

#ud
index=1
 while [ 1 ]
 do
    while [ 1 ]
    do
	tarih=`date +%Y%m%d`
        logfile=/home/turkmud/turkmud/log/$tarih"_"$index.log
        if [ -r $logfile ]
        then
                 index=`expr $index + 1`
        else
                 break
        fi
    done

    cd /home/turkmud/turkmud/area
    /home/turkmud/turkmud/area/turkmud $* >$logfile 2>&1
    #/virtual/uzakdiyarlar.com/mud-anatolia/area/ud

    if [ -r shutdown.txt ]
    then
      rm -f shutdown.txt
      break
    fi

    if [ -r core ]
    then
      mv core "../core."$tarih"_"$index
    fi
   sleep 10
done